package com.zwd.deep.controller;


import com.zwd.deep.common.RequestResult;
import com.zwd.deep.entity.dto.AppointmentsCheckDTO;
import com.zwd.deep.entity.dto.AppointmentsDTO;
import com.zwd.deep.entity.vo.AppointmentsVo;
import com.zwd.deep.service.IAppointmentsService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 预约时间表
 *
 * @author zwd
 * @since 2025-02-12
 */
@RestController
@RequestMapping("/appointments")
@AllArgsConstructor
@Slf4j
@Validated
public class AppointmentsController {
    private final IAppointmentsService appointmentsService;

    /**
     * 查询预约时间
     * @param appointmentsCheckDTO 日期
     * @return 预约时间段状态
     */
    @PostMapping("/check")
    public RequestResult<List<AppointmentsVo>> check(@RequestBody @Validated AppointmentsCheckDTO appointmentsCheckDTO) {
        List<AppointmentsVo> appointmentsVoList = appointmentsService.check(appointmentsCheckDTO);
        return RequestResult.success(appointmentsVoList);
    }

    /**
     * 创建预约
     * @param appointmentsDTO 预约参数
     * @return 预约结果
     */
    @PostMapping
    public RequestResult<Boolean> register(@Validated @RequestBody AppointmentsDTO appointmentsDTO) {
        appointmentsService.saving(appointmentsDTO);
        return RequestResult.bool(true);
    }

}
